from typing import List


class AuthenticationManager:

    def __init__(self, timeToLive: int):
        self.timeToLive = timeToLive
        self.token_map = {}

    def generate(self, tokenId: str, currentTime: int) -> None:
        self.token_map[tokenId] = currentTime

    def renew(self, tokenId: str, currentTime: int) -> None:
        if (tokenId in self.token_map) and (self.token_map[tokenId]+self.timeToLive > currentTime):
            self.token_map[tokenId] = currentTime

    def countUnexpiredTokens(self, currentTime: int) -> int:
        count = 0
        for t in self.token_map.keys():
            if self.token_map[t]+self.timeToLive > currentTime:
                count += 1
        return count


obj = AuthenticationManager(13)
print(obj.renew('ajvy', 1))
print(obj.countUnexpiredTokens(3))
print(obj.countUnexpiredTokens(4))
print(obj.generate('fuzxq', 5))
print(obj.generate('izmry', 7))
print(obj.renew('puv', 12))
print(obj.generate('ybiqb', 13))
print(obj.generate('gm', 14))
print(obj.countUnexpiredTokens(15))
print(obj.countUnexpiredTokens(18))
print(obj.countUnexpiredTokens(19))
print(obj.renew('ybiqb', 21))
print(obj.countUnexpiredTokens(23))
print(obj.countUnexpiredTokens(25))
print(obj.countUnexpiredTokens(26))
print(obj.generate('aqdm', 28))
print(obj.countUnexpiredTokens(29))
print(obj.renew('puv', 30))


def gen_code(func: List[str], param: List[List[str]]) -> None:
    for i in range(len(func)):
        method_str=""
        if func[i] == 'AuthenticationManager':
            method_str="obj="+func[i]
        else:
            method_str="print(obj."+func[i]

        if len(param[i]) == 1:
            method_str += "(" + str(param[i][0]) + "))"
        else:
            method_str += "('" + param[i][0] + "', " + str(param[i][1]) + "))"

        print(method_str)


# gen_code(["AuthenticationManager", "renew", "countUnexpiredTokens", "countUnexpiredTokens", "generate", "generate", "renew", "generate", "generate", "countUnexpiredTokens", "countUnexpiredTokens", "countUnexpiredTokens", "renew", "countUnexpiredTokens", "countUnexpiredTokens",
#          "countUnexpiredTokens", "generate", "countUnexpiredTokens", "renew"], [[13], ["ajvy", 1], [3], [4], ["fuzxq", 5], ["izmry", 7], ["puv", 12], ["ybiqb", 13], ["gm", 14], [15], [18], [19], ["ybiqb", 21], [23], [25], [26], ["aqdm", 28], [29], ["puv", 30]])
